package com.cuitrip.util;

import com.lab.rtenvironment.AppCoreRuntime;

import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

/**
 * 国际化工具
 * Created by ak on 15/9/22.
 */
public class I118Util {


    public static boolean isSimplifiedChinese() {
        return getLocale().equals(Locale.SIMPLIFIED_CHINESE);
    }

    /**
     * 获取语言tag
     *
     * @return
     */
    public static String getLanguageTag() {
        Locale locale = getLocale();
        if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
            return locale.getLanguage();
        }
        String languageTag = locale.toString().replaceAll("_", "-");
        return languageTag;
    }

    public static String getH5LanguageTag() {
        Locale locale = getLocale();
        if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
            return locale.getLanguage();
        }
        String languageTag = locale.toString();
        if (languageTag.equalsIgnoreCase("zh_HK")) {
            languageTag = Locale.TAIWAN.toString();
        }
        return languageTag;
    }

    public static String getSupportLanguageTag() {
        Locale locale = getLocale();
        if (locale.getLanguage().equals(Locale.CHINESE.getLanguage())){
            String languageTag = locale.toString();
            if (languageTag.equalsIgnoreCase("zh_HK")) {
                languageTag = Locale.TAIWAN.toString();
            }
            return languageTag;
        }

//        if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
            return Locale.ENGLISH.getLanguage();
//        }
//        return languageTag;
    }

    public static Locale getLocale() {
        return AppCoreRuntime.context.getResources().getConfiguration().locale;
    }

    public static CtLocale getCtLocale() {
        return CtLocale.valueOf(getLocale());
    }
    public static TimeZone getTimeZone() {
        return Calendar.getInstance().getTimeZone();
    }
}
